#include<iostream>
#include<stdio.h>
#include<string.h>
#include<errno.h>

int main()
{
    FILE*fp=fopen("./date","w+");
    if(fp==nullptr)
    {
    std::cout<<strerror(errno)<<std::endl;
    return -1;
    }
    const char *s="linux so easy!";
    ssize_t ret=fwrite(s,1,strlen(s),fp);
    if(ret!=strlen(s))
    {
    std::cout<<strerror(errno)<<std::endl;
    return -1;
    }
    fseek(fp,0,SEEK_SET);
    char buffer[1024]={0};
    ret=fread(buffer,1,1023,fp);
    if(ret==0)
    {
    if(ferror(fp))
    {
        printf("fread error\n");
    }
    if(feof(fp))
    {
        printf("read end of file\n");
    }
    }
    printf("%s",buffer);
    fclose(fp);
    return 0;

}